package cn.wolfcode.p2p.base.domain;

import cn.wolfcode.base.BaseDomain;
import java.util.Date;
import lombok.Getter;
import lombok.Setter;
import lombok.experimental.Accessors;

/**
 *    
 *    
 *    @author 
 *    @since 2018-11-24 19:25:54
 */
@Getter@Setter
@Accessors(chain = true)
public class IpLog extends BaseDomain {
    /**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	public static final Integer STATE_SUCCESS = 0; // 登录成功
    public static final Integer STATE_FAILING = 1; // 登录失败


    /**
     * 登录IP
     */
    private String ip;

    /**
     * 登录账户名称
     */
    private String username;

    /**
     * 登录时间
     */
    private Date loginTime;

    /**
     * 登录状态(成功/失败)
     */
    private Integer state;

    /**
     * 用户类型(前台用户/后台用户)
     */
    private Integer userType = LoginInfo.TYPE_USER;

    public String getDisplayState(){
        String displayState = "登录成功";
        if (this.state == STATE_FAILING){
            displayState = "登录失败";
        }
        return displayState;
    }

    public String getDisplayUserType(){
        return userType == LoginInfo.TYPE_USER ? "前台用户" : "管理员";
    }
}